<template>
  <el-container class="firm-mg">
    <el-container>
      <el-aside width="200px">
        <el-menu :default-active="menuActive" @select="selectMenu">
          <el-menu-item
            v-for="item in menuList"
            :key="item.key"
            :index="item.key"
          >
            {{ item.title }}
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <transition name="fade-transform" appear mode="out-in">
          <keep-alive>
            <component :is="menuActive" />
          </keep-alive>
        </transition>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { mapGetters } from 'vuex'
import FirmInfo from './component/firmInfo'
import PurchasedServices from './component/purchasedServices'
import UserMg from './component/userMg'
import DataConnect from './component/DataConnect'

export default {
  name: 'Dashboard',
  components: {
    FirmInfo,
    PurchasedServices,
    UserMg,
    DataConnect
  },
  data() {
    const menuKeys = {
      info: 'FirmInfo',
      servies: 'PurchasedServices',
      connect: 'DataConnect',
      user: 'UserMg'
    }
    return {
      menuList: [
        { key: menuKeys.info, title: this.$t('firm.information') },
        // { key: menuKeys.servies, title: '购买服务' },
        // { key: menuKeys.connect, title: '数据连接' },
        { key: menuKeys.user, title: this.$t('firm.userManagement') }
      ],
      menuActive: menuKeys.info
    }
  },
  computed: {
    ...mapGetters(['userName'])
  },
  methods: {
    selectMenu(key) {
      this.menuActive = key
    }
  }
}
</script>

<style lang="scss" scoped>
.firm-mg {
  background: #fff;
  >>> .el-input {
    max-width: 450px;
  }
  .el-aside {
    height: calc(100vh - 100px);
    box-shadow: 0px 1px 9px #e6e9ec;
  }
}
</style>
